#ifndef SOUND_H
#define SOUND_H

#include <SDL_mixer.h>
#include <string>
#include <sndfile.h>

class Sound
{
public:
	Sound();

	bool LoadSound(const std::string& file);
	void SaveSound(const std::string& filename);

	void SetVolume(float f);
	void SetNormalised(bool b);
	void SetReversed(bool b);
	void SetNumOfLoops(int i);
	void SetLPFilter(float f);
	void SetHPFilter(float f);
	void SetMaxFreq(float f);
	void SetMinFreq(float f);
	void SetFrequency(float f);
	void SetFadeInAmount(float f);
	void SetFadeOutAmount(float f);

	
	bool GetWasChanged() const;

	void Play();
private:
	void Reload();
	void CalculateSignal(const std::string& bufferPath);
	float LPF(float signal, float cf);

private:
	float m_volume;
	float m_lpFilter;
	float m_fadeIn;
	float m_fadeOut;
	float m_minFreq;
	float m_maxFreq;
	float m_frequency;
	float m_origFreq;

	bool m_normalised;
	bool m_reversed;

	std::string m_filePath;
	std::string m_saveFilePath;

	float* m_dataOrig;
	float* m_dataMod;
	float* m_dataReversed;

	SNDFILE* m_fileHandle;
	SF_INFO m_fileInfo;

	int m_totalNumOfFrames;

	Mix_Chunk* m_sound;

	int m_numOfLoops;
	bool m_wasChanged;

	float m_maxVal;
};

#endif //SOUND_H